#pragma once
#include <JeayeSDK/JeayeSDK.h>
/**/
#define c_array_for_each(__TYPE, __VAL, __KEY, __FIRST, __OP)\
do { \
    __TYPE* __VAL = NULL;\
    UINT32 __COUNT = c_array_get_count(__FIRST), __KEY = 0;\
    for (__KEY = 0; __KEY < __COUNT; __KEY++) { \
        __VAL = (__TYPE*)c_array_find(__FIRST, __KEY);\
        __OP \
    }\
} while ( 0 )
/**/
#define c_array_count c_array_get_count
class JEAYESDK_API JArray
{
public:
	UINT size;
	PVOID *data;
	UINT count;
public:
	JArray(UINT initsize);
	~JArray();
	BOOL create(UINT initsize);
	UINT get_count(){ return this->count; }
	void* begin(){ return this->data[0];}
	void* end(){ return this->data[this->count - 1];}
	void* find(const UINT index);
	void append(const JArray* append);
	void insert(const UINT index,void* data);
	void push(void* val){ return insert(this->count, val); }
	void* pop();
	void* remove(const UINT index);
	void cleanup();
	void destroy();
};